package com.zone.vehicle.superapp.utils;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;

/**
 * @Author: pkqlqx
 * @CreateDate: 2022/1/20 17:45
 * @Description:
 */
public class JDUtil {
    private static final String TAG = JDUtil.class.getSimpleName();

    public static void start(Context context, String appId, String appType){
        StringBuilder uri = new StringBuilder();
        uri.append("mantozone://tango?params={\"des\":\"vapp\",\"appId\":\"");
        uri.append(appId);
        uri.append("\",\"appType\":\"");
        uri.append(appType);
        uri.append("\"}");
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);
        //"mantozone://tango?params={\"des\":\"vapp\",\"appId\":\"4516166309802406CDE7ECA4E2BC23B2\",\"appType\":\"2\"}"
        Log.d(TAG, "JD-start app="+uri.toString());
        intent.setData(Uri.parse(uri.toString()));
        try {
            context.startActivity(intent);
        } catch (Exception e){
            Log.e(TAG, e.toString());
        }
    }

    public static void delete(Context context, String appId, String appType){
        StringBuilder uri = new StringBuilder();
        uri.append("mantozone://tango?params={\"des\":\"delvapp\",\"appId\":\"");
        uri.append(appId);
        uri.append("\",\"appType\":\"");
        uri.append(appType);
        uri.append("\"}");
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);
        //"mantozone://tango?params={\"des\":\"vapp\",\"appId\":\"4516166309802406CDE7ECA4E2BC23B2\",\"appType\":\"2\"}"
        Log.d(TAG, "JD-delete app="+uri.toString());
        intent.setData(Uri.parse(uri.toString()));
        try {
            context.startActivity(intent);
        }catch (ActivityNotFoundException e){
            Log.e(TAG, e.toString());
        }catch (Exception e){
            Log.e(TAG, e.toString());
        }
    }


}
